<?php
use yii\bootstrap\ActiveForm;
?>
<link rel="stylesheet" href="../static/dist/css/AdminLTE.min.css" type="text/css">
<link rel="stylesheet" href="../static/bootstrap/css/bootstrap.min.css" type="text/css">
<link rel="stylesheet" href="../static/plugins/datatables/jquery.dataTables.css" type="text/css">
<link rel="stylesheet" href="../static/css/admin.css" type="text/css">
<link rel="stylesheet" href="../static/jBox/Skins/Metro/jbox.css" type="text/css">
<link rel="stylesheet" href="../static/plugins/treeTable/jquery.treetable.css" type="text/css">
<link rel="stylesheet" href="../static/plugins/treeTable/jquery.treetable.theme.default.css" type="text/css">

<style>
    .ul_tree_display{
        display: none;
    }
    .tr_tree_display{
        display: none;
    }
    .dataTables_length{
        margin-top: 10px;
    }
    .dataTable>tbody>tr>td{
        vertical-align: middle;
        font-size: 0.8em;
        padding: 8px 18px;
    }
    .dataTable>thead>tr>th{
        vertical-align: middle;
        font-size: 0.8em;
    }
    .table>tbody>tr>td{
        vertical-align: middle;
        font-size: 0.8em;
    }
</style>
<div class="tabs-panel">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <!--<h3 class="box-title">Hover Data Table</h3>-->
                    角色名称: <input class="depart-input" name="role_name" id="role_name" type="text" placeholder="">
                    <button type="button" class="btn btn-primary depart-modal" id="select_button" style="width: 100px;">查询</button> &nbsp;
                    <button type="button" class="btn btn-warning depart-modal" id="reset_button" style="width: 100px;">重置</button>
                    <!--部门:<select name="dept_id" id="dept_id"></select>-->
                </div>
                <!-- /.box-header -->
                <div class="box-body">
                    <button type="button" class="btn btn-success depart-modal" id="add_button" style="width: 100px;">添加</button>
                    <table id="table_list" class="display">
                        <thead>
                        <tr>
                            <th style="width: 10%">操作</th>
                            <th style="width: 7%">角色ID</th>
                            <th style="width: 20%">角色名称</th>
                            <th style="width: 20%">角色组名称</th>
                            <th style="width: 20%">备注</th>
                            <th style="width: 5%"><?=TITLE_STATUS?></th>
                        </tr>
                        </thead>
                        <tbody>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>

    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h4 class="modal-title" id="myModalLabel">
                        修改角色
                    </h4>
                </div>
                <div class="modal-body">
                    <?php $form = ActiveForm::begin([
                        'id'     => 'user_form',
                        'action' => ['/sys-role/update-role']
                    ]); ?>
                    <!--<form action="/setting/add-depart" method="post" id="depart_form">-->
                    <div class="box-body">
                        <div class="form-group">
                            <label for="role_group_id">角色组</label>

                            <select id="role_group_id" name="role_group_id" class="form-control" style="width: 50%;">
                                <option value="0">请选择</option>
                            </select>
                        </div>

                        <div class="form-group">
                            <label for="mobile">角色名称</label>
                            <input type="text" style="width: 50%;" class="form-control" name="role_name" id="role_name_other" placeholder="角色名称">
                        </div>

                        <div class="form-group">
                            <label for="exampleInputEmail1">状态</label>
                            <select id="use_flg" name="use_flg" class="form-control" style="width: 50%;">
                                <option value="1">启用</option>
                                <option value="0">禁用</option>
                            </select>
                        </div>

                        <div class="form-group">
                            <label for="exampleInputPassword1">备注</label>
                            <textarea class="form-control" name="memo" id="memo" rows="3" placeholder="" ></textarea>
                        </div>

                        <input type="hidden" style="width: 50%;" name="id" class="form-control" id="id">
                    </div>
                    <!-- /.box-body -->

                    <?php ActiveForm::end(); ?>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                    </button>
                    <a type="button" class="btn btn-primary ajax_post_depart">
                        提交
                    </a>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>

    <div class="modal fade" id="role-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h4 class="modal-title" id="myModalLabel">
                        添加角色
                    </h4>
                </div>
                <div class="modal-body">
                    <form action="/sys-role/add-role" method="post" id="role_form">
                    <div class="box-body">
                        <div class="form-group">
                            <label for="role_group_id">角色组</label>

                            <select id="role_group_id_other" name="role_group_id" class="form-control" style="width: 50%;">
                                <option value="0">请选择</option>
                            </select>
                        </div>

                        <div class="form-group">
                            <label for="mobile">角色名称</label>
                            <input type="text" style="width: 50%;" class="form-control" name="role_name" id="add_role_name" placeholder="角色名称">
                        </div>

                        <div class="form-group">
                            <label for="exampleInputEmail1">状态</label>
                            <select name="use_flg" class="form-control" style="width: 50%;">
                                <option value="1">启用</option>
                                <option value="0">禁用</option>
                            </select>
                        </div>

                        <div class="form-group">
                            <label for="exampleInputPassword1">备注</label>
                            <textarea class="form-control" name="memo" id="memo" rows="3" placeholder="" ></textarea>
                        </div>

                    </div>
                    <!-- /.box-body -->
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                    </button>
                    <a type="button" class="btn btn-primary ajax_post_role">
                        提交
                    </a>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>

    <div class="modal fade" id="rule-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h4 class="modal-title" id="myModalLabel">
                        权限设置
                    </h4>
                </div>
                <div class="modal-body">
                <form id="rule_form" action="/sys-role/add-rules">

                    <table id="example2" class="table table-bordered table-hover">
                        <tbody>
                        <?php if(!empty($menu_list)){?>
                            <?php foreach ($menu_list as $key => $val) {?>
                                <tr data-tt-id="<?= $val['id']?>" data-tt-parent-id="<?= $val['parent_id']?>" class="">
                                    <td class="" style="width: 250px;padding-left: 20px;">
                                        <span><?= $val['html']?>

                                        <input type="checkbox" name="rules[]" value="<?= $val['id']?>"><?= $val['name']?>
                                        </span>
                                    </td>
                                </tr>
                            <?php } ?>
                        <?php }else{?>
                            <tr><td colspan="8" style="text-align: center">暂无菜单！</td></tr>
                        <?php }?>
                        </tfoot>
                    </table>
                    <input type="hidden" style="width: 50%;" name="role_id" class="form-control" id="role_id">
                </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                    </button>
                    <a type="button" class="btn btn-primary ajax_post_rules">
                        提交
                    </a>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>
</div>
<!-- 固定js -->
<script type="text/javascript" src="../static/plugins/jQuery/jquery-2.2.3.min.js"></script>
<script type="text/javascript" src="../static/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../static/plugins/datatables/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="../static/plugins/datatables/dataTables.bootstrap.min.js"></script>
<script type="text/javascript" src="../static/jBox/jquery.jBox-2.3.min.js"></script>
<script type="text/javascript" src="../static/jBox/i18n/jquery.jBox-zh-CN.js"></script>
<script type="text/javascript" src="../static/plugins/treeTable/jquery.treetable.js"></script>
<!-- 自定义js -->
<script type="text/javascript" src="/static/app/global.js?version=<?=Yii::$app->params['version']?>"></script>
<script type="text/javascript" src="../static/app/sys-role/index.js?version=<?=Yii::$app->params['version']?>"></script>